import Vue from 'vue'

var config = require('../../../config')

Vue.component('button-component',{
  template:['<button @click="click(rowdata[col])">{{rowdata[col]}}</button>'].join(''),
  props:['rowdata','col'],
  methods: {
    click: function (value) {
      alert('这个按钮名字是'+value)
    }
  }
})

var a  = Vue.component('a-component',{
  template:['<a href="#" @click="click(rowdata[col])">{{rowdata[col]}}</a>'].join(''),
  props:['rowdata','col'],
  methods: {
    click: function (value) {
      alert('这个\<a\>的名字是'+value)
    }
  }
})

console.log('================')
console.log(a)
console.log('================')


Vue.component('delete-component',{
  template:['<button @click="click(rowdata)">删除</button>'].join(''),
  props:['rowdata','col'],
  methods: {
    click: function (value) {
      var stuid = value.stuid
      alert(stuid)
      var self = this
      this.$axios.delete(config.dev.server+'/vue/main/delStudent.json?stuid='+stuid)
        .then(function (json) {
          alert('删除成功')
          self.$emit('init')
          console.log(json);
        })
        .catch( function (error) {
          alert('删除失败')
          console.log(error);
        });
    }
  }
})
